package cn.nfwx.tv.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;

import com.tmall.ultraviewpager.UltraViewPager;

import cn.nfwx.tv.util.LogUtil;

public class TouchUltraViewPager extends UltraViewPager {

    private boolean mDisable;

    public void setTouchListener(OnTouchListener onTouchListener) {
        this.onTouchListener = onTouchListener;
    }

    public void setDisable(boolean disable) {
        mDisable = disable;
    }

    public interface OnTouchListener {
        void touchEvent(MotionEvent event);
    }

    private OnTouchListener onTouchListener;

    public TouchUltraViewPager(Context context) {
        super(context);
    }

    public TouchUltraViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
    }


    @Override
    public boolean onInterceptTouchEvent(MotionEvent event) {
        LogUtil.v("NfwxVideoPlayerController", "onInterceptTouchEvent--TouchUltraViewPager--" + event.getAction());
        if(mDisable){
            return true;
        }
        return super.onInterceptTouchEvent(event);
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent event) {
        LogUtil.v("NfwxVideoPlayerController", "dispatchTouchEvent--TouchUltraViewPager--" + event.getAction()+"---"+mDisable);
        if (onTouchListener != null) {
            onTouchListener.touchEvent(event);
        }
        return super.dispatchTouchEvent(event);
    }
}
